
package com.wyzz.hr.action;

import java.util.*;
import org.apache.axis.utils.StringUtils;

import com.wyzz.hr.base.BaseAction;
import com.wyzz.hr.base.ComonBeans;
import com.wyzz.hr.bo.IEmpContractBo;
import com.wyzz.hr.bo.IEmpEvalBo;
import com.wyzz.hr.bo.IEmpQuitBo;
import com.wyzz.hr.bo.IEmpRewardBo;
import com.wyzz.hr.bo.IEmpTransferBo;
import com.wyzz.hr.bo.IEmployeeBo;
import com.wyzz.hr.pojo.Employee;
import com.wyzz.hr.pojo.Empquit;
import com.wyzz.hr.pojo.Empreward;

public class EmpProfile extends BaseAction {

	public EmpProfile() {
		erTypeMap = ComonBeans.getValuesToMap(Empreward.PROP_ER_TYPE,
				new boolean[0]);
		erFormMap = ComonBeans.getSecondLevelSelect(erTypeMap,
				Empreward.PROP_ER_FORM, new boolean[0]);
	}

	public String execute() throws Exception {
		if (StringUtils.isEmpty(empNo) || empNo.equals("null"))
			empNo = getCurrentEmpNo();
		IEmployeeBo empBo = (IEmployeeBo) getBean("empBo");
		currentEmp = empBo.loadEmp(empNo, new String[] {
				Employee.PROP_EMP_DEPT_NO, Employee.PROP_EMP_PB_NO,
				Employee.PROP_EMP_TYPE });
		if (currentEmp == null)
			return "noemp";
		empName = currentEmp.getEmpName();
		empStatus = false;
		if (currentEmp.getEmpStatus().equals(Integer.valueOf(1)))
			empStatus = true;
		if (!empNo.equals(getCurrentEmpNo())) {
			if ("OWN".equals(super.authorityCondition))
				return "noauth";
			if (("SUB".equals(super.authorityCondition) || "HRSUB"
					.equals(super.authorityCondition))
					&& !checkEmpInCharge(currentEmp, 1))
				return "noauth";
		}
		IEmpContractBo empContractBo = (IEmpContractBo) getBean("empContractBo");
		contractList = empContractBo.searchByEmpNo(empNo);
		empTypeList = empBo.getObjects(com.wyzz.hr.pojo.ContractType.class,
				null);
		IEmpTransferBo empTransfer = (IEmpTransferBo) getBean("empTransferBo");
		transferList = empTransfer.findTransferByEmpNo(empNo);
		IEmpEvalBo empEval = (IEmpEvalBo) getBean("empEvalBo");
		evalList = empEval.findEvalByEmpNo(empNo);
		IEmpRewardBo empReward = (IEmpRewardBo) getBean("empRewardBo");
		rewardList = empReward.findRewardByEmpNo(empNo);
		IEmpQuitBo empQuit = (IEmpQuitBo) getBean("empQuitBo");
		quitList = empQuit.searchByEmpNo(empNo);
		deptList = getDrillDown("Department", new String[0]);
		empTypes = getDrillDown("EmpType", new String[0]);
		setQRMap();
		return "success";
	}

	private void setQRMap() {
		eqTypeMap = ComonBeans.getValuesToMap(Empquit.PROP_EQ_TYPE,
				new boolean[0]);
		eqReasonMap = ComonBeans.getSecondLevelSelect(eqTypeMap,
				Empquit.PROP_EQ_REASON, new boolean[0]);
		eqRTypeMap = new TreeMap();
		eqRReasonMap = new TreeMap();
		eqRTypeMap.put("1", eqTypeMap.get("1"));
		eqRReasonMap.put("1", eqReasonMap.get("1"));
		eqTypeMap.remove("1");
		eqReasonMap.remove("1");
	}

	public List getContractList() {
		return contractList;
	}

	public void setContractList(List contractList) {
		this.contractList = contractList;
	}

	public String getEmpNo() {
		return empNo;
	}

	public void setEmpNo(String empNo) {
		this.empNo = empNo;
	}

	public String getEmpName() {
		return empName;
	}

	public void setEmpName(String empName) {
		this.empName = empName;
	}

	public List getEmpTypeList() {
		return empTypeList;
	}

	public void setEmpTypeList(List empTypeList) {
		this.empTypeList = empTypeList;
	}

	public List getTransferList() {
		return transferList;
	}

	public void setTransferList(List transferList) {
		this.transferList = transferList;
	}

	public List getDeptList() {
		return deptList;
	}

	public void setDeptList(List deptList) {
		this.deptList = deptList;
	}

	public List getEvalList() {
		return evalList;
	}

	public void setEvalList(List evalList) {
		this.evalList = evalList;
	}

	public List getRewardList() {
		return rewardList;
	}

	public void setRewardList(List rewardList) {
		this.rewardList = rewardList;
	}

	public List getQuitList() {
		return quitList;
	}

	public void setQuitList(List quitList) {
		this.quitList = quitList;
	}

	public boolean isEmpStatus() {
		return empStatus;
	}

	public Employee getCurrentEmp() {
		return currentEmp;
	}

	public void setCurrentEmp(Employee currentEmp) {
		this.currentEmp = currentEmp;
	}

	public void setEmpStatus(boolean empStatus) {
		this.empStatus = empStatus;
	}

	public Map getErTypeMap() {
		return erTypeMap;
	}

	public Map getErFormMap() {
		return erFormMap;
	}

	public Map getEqTypeMap() {
		return eqTypeMap;
	}

	public Map getEqReasonMap() {
		return eqReasonMap;
	}

	public Map getEqRTypeMap() {
		return eqRTypeMap;
	}

	public Map getEqRReasonMap() {
		return eqRReasonMap;
	}

	public List getEmpTypes() {
		return empTypes;
	}

	public void setEmpTypes(List empTypes) {
		this.empTypes = empTypes;
	}

	private static final long serialVersionUID = 1L;
	private List contractList;
	private List empTypeList;
	private String empNo;
	private String empName;
	private List transferList;
	private List evalList;
	private List rewardList;
	private List quitList;
	private List deptList;
	private boolean empStatus;
	private Employee currentEmp;
	private List empTypes;
	private Map erTypeMap;
	private Map erFormMap;
	private Map eqTypeMap;
	private Map eqReasonMap;
	private Map eqRTypeMap;
	private Map eqRReasonMap;
}
